<template>
  <div class="photoinfo-container">
    <h3>{{ photoinfo.title }}</h3>
    <p class="subtitle">
      <span>发表时间：{{ photoinfo.add_time }}</span>
      <span>点击：{{ photoinfo.click }}次</span>
    </p>

    <hr>

    <!-- 缩略图区域 -->
    <vue-preview
    :list="list"
    :thumbImageStyle="{width: '80px', height: '80px', margin: '10px', boxShadow: '0 0 9px #999'}"
    :tapToClose="true"
    />

    <!-- 图片内容区域 -->
    <div class="content" v-html="photoinfo.content"></div>

    <!-- 评论区域 -->
    <comment-box></comment-box>
  </div>
</template>

<script>
import comment from '../subcomponents/Comment.vue'

export default {
  data(){
    return {
      id: this.$route.params.id,
      com_name: this.$route.params.com_name,
      photoinfo: {},
      list: []
    }
  },
  created(){
    this.getPhotoInfo()
    this.getThumbs()
  },
  methods: {
    getPhotoInfo(){
      this.$http.get('photoinfo.php?id=' + this.id).then(result=>{
        if (result.body.status === 0) {
          this.photoinfo = result.body.message[0]
        }
      })
    },
    getThumbs(){
      this.$http.get('thumbs.php?com_name=' + this.com_name + '&id=' + this.id).then(result => {
        if (result.body.status === 0) {
          result.body.message.forEach(item => {
            item.w = 600
            item.h = 600
          })
          this.list = result.body.message
        }
      })
    }
  },
  components: {
    'comment-box': comment
  }
}
</script>

<style lang="scss" scoped>
.photoinfo-container{
  padding: 3px;

  h3{
    margin: 15px 0;
    text-align: center;
    color: #26A2FF;
    font-size: 15px;
  }

  .subtitle{
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }

  .content{
    font-size: 13px;
    line-height: 30px;
  }
}
</style>
